<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.14.
   家居公司设计作品显示($$)*/

!defined('Q_PATH') && exit;

class Caseshow_C_Controller extends InitController{

	public function index(){
		$arrJiajucompany=$this->_oParent->_arrJiajucompany;
		$nId=intval(Q::G('id','G'));

		if(!$nId){
			$this->page404();
		}

		// 作品显示
		$arrWhere=array();
		$arrWhere['A.jiajucase_status']=1;
		$arrWhere['A.jiajucase_id']=$nId;
		$arrWhere['A.jiajucompany_id']=$arrJiajucompany['jiajucompany_id'];

		if(ACTION_NAME==='room_show'){
			$arrWhere['A.jiajucase_ismodel']=1;
		}

		$arrCase=Model::F_('jiajucase','@A')
			->setColumns('A.jiajucase_id,A.jiajucase_title,A.jiajucase_designerid,A.jiajucase_styleid,A.jiajucase_spaceid,A.jiajucase_areaid,A.jiajucase_realspace,A.jiajucase_priceid,A.jiajucase_realprice,A.jiajucase_viewnum,A.jiajucase_likenum,A.jiajucase_commentnum,A.jiajucase_pics,A.jiajucase_thumb,A.jiajucase_picnum')
			->where($arrWhere)
			->join(Q::C('DB_PREFIX').'jiajucasecontent AS B','B.jiajucase_content','A.jiajucase_id=B.jiajucase_id')
			->joinLeft(Q::C('DB_PREFIX').'jiajudesigner AS C','C.jiajudesigner_name AS designer_name','A.jiajucase_designerid=C.jiajudesigner_id')
			->joinLeft(Q::C('DB_PREFIX').'jiajucompanyclass AS D','D.jiajucompanyclass_name AS style_name','A.jiajucase_styleid=D.jiajucompanyclass_id')
			->joinLeft(Q::C('DB_PREFIX').'jiajucompanyclass AS E','E.jiajucompanyclass_name AS space_name','A.jiajucase_spaceid=E.jiajucompanyclass_id')
			->getOne();

		if(empty($arrCase['jiajucase_id'])){
			$this->page404();
		}

		// 更新点击量
		Model::M_('jiajucase')->updateWhere(array('jiajucase_viewnum'=>$arrCase['jiajucase_viewnum']+1),'jiajucase_id=?',$nId);
		$arrCase['jiajucase_viewnum']++;

		if(ACTION_NAME==='room_show'){
			Core_Extend::getSeo($this,array(
				'title'=>"{$arrCase['jiajucase_title']}样板房",
				'keywords'=>"{$arrCase['style_name']}{$arrCase['space_name']},{$arrCase['style_name']}{$arrCase['space_name']}样板房,{$arrCase['style_name']}{$arrCase['space_name']}样板房,{$arrCase['style_name']}风格{$arrCase['jiajucase_title']}样板房",
				'description'=>"样板房专区，由{$GLOBALS['_option_']['site_name']}提供当前国内外最新流行的成套{$arrCase['jiajucase_title']}，{$GLOBALS['_option_']['site_name']}样板房，{$GLOBALS['_option_']['site_name']}装修效果图经典样板房，欢迎大家欣赏！",
			));
		}else{
			Core_Extend::getSeo($this,array(
				'title'=>"{$arrCase['jiajucase_title']}装修设计效果图",
				'keywords'=>"{$arrCase['style_name']}{$arrCase['space_name']},{$arrCase['style_name']}{$arrCase['space_name']}设计,{$arrCase['style_name']}{$arrCase['space_name']}装修图片,{$arrCase['style_name']}风格{$arrCase['jiajucase_title']}整套装修案例",
				'description'=>"整套装修案例专区，由{$GLOBALS['_option_']['site_name']}提供当前国内外最新流行的成套{$arrCase['jiajucase_title']}，{$GLOBALS['_option_']['site_name']}装修效果图，{$GLOBALS['_option_']['site_name']}装修效果图经典设计案例，欢迎大家欣赏！",
			));
		}

		if($arrCase['jiajucase_pics']){
			$arrCasepics=json_decode($arrCase['jiajucase_pics'],true);
		}else{
			$arrCasepics=array();
		}

		$this->assign('arrCase',$arrCase);
		$this->assign('arrCasepics',$arrCasepics);
		$this->display(Jiaju_Extend::getTemplate($arrJiajucompany,'caseshow'));
	}

}
